send("]] *** Heavy Sysop Stuff BE CAREFUL HERE !! ***]]");
if (!(cmd1(">> Edit user, User list, Verify user list, Quit :"))) goto byebye; /* timeout */
send (G->CR[u]);
switch (G->input[u]) {
case 'E':
edituserinfo();
break;
case 'U':
listusers();
break;
case 'V':
checkuserlist();
break;
case 'Q': /* Quit */
return;
break;
}
if (!G->online[u]) goto byebye; /* log out */
goto okpass;
byebye:
G->online[u]=FALSE; /* show we timed out */
return;
}
getpass()
{
char temp[40];
char password[40];
FILE *stream;
if ((stream = fopen(":bbssupport:sysopstuff", "r")) == NULL) {
send("] ERROR ! Cannot open 'sysopstuff' file !!]");
return FALSE;
}
else {
fscanf(stream,"%30[^\n]\n",password);
fclose(stream);
}
strtoupper(password); /* uppercase the password */
send("]Sysop Password :");
passportsin(temp, 30);
strtoupper(temp); /* uppercase the password */
send(G->CR[u]);
if (! G->online[u]) return FALSE; /* returns online for a time out */
if (strcmp(password,temp) == 0) {
return TRUE;
}
return FALSE;
}
listusers()
{
char tempname[maxnamelength];
char tempalias[maxnamelength];
char temppass[maxnamelength];
char tempaddress[maxnamelength];
char tempcity[maxnamelength];
char tempphone[maxnamelength];
char tempmachine[maxnamelength];
char tempfirst[maxnamelength];
char templevel[maxnamelength];
char tempsettings[maxnamelength];
char tempbirth[maxnamelength];
char tempextras1[maxnamelength];
char tempextras2[maxnamelength];
char tempmins[maxnamelength];
char temptimes[maxnamelength];
char templast[maxnamelength];
char tempupdown[maxnamelength];
char tempcomments[260];
char tchar[260], temp[65];
int lnum,tempint,got,chars;
long int pos;
FILE *stream;
send("]User List Printout :]]");
if ((stream = fopen(":user:userlist", "r")) == NULL) {
print("C> FILE ERROR - cannot open user:userlist\n");
send("]FILE ERROR - Can't open the user list file !]");
goto endthis;
}
more:
pos = ftell(stream); /* get the current file position */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempname); /* the user's name */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempalias); if (feof(stream)) goto goteof; /* the user's alias */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",temppass); if (feof(stream)) goto goteof; /* the user's password */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",templevel); if (feof(stream)) goto goteof; /* the user's access level */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempaddress); if (feof(stream)) goto goteof; /* the user's address */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempcity); if (feof(stream)) goto goteof; /* the user's city and state */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempphone); if (feof(stream)) goto goteof; /* the user's phone number */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempmachine); if (feof(stream)) goto goteof; /* the user's machine */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempfirst); if (feof(stream)) goto goteof; /* date first logged in */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempsettings); if (feof(stream)) goto goteof; /* user's settings */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempbirth); if (feof(stream)) goto goteof; /* birth info */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempextras1); if (feof(stream)) goto goteof; /* any other info for later use */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempextras2); if (feof(stream)) goto goteof; /* any other info for later use */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",temptimes); if (feof(stream)) goto goteof; /* the number of times this user has been on */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",templast); if (feof(stream)) goto goteof; /* the last date user was on */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempmins); if (feof(stream)) goto goteof; /* the time the user was on last time */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempupdown); if (feof(stream)) goto goteof; /* uploads/downloads */
fgets(tchar,258,stream); sscanf(tchar,"%255[^~]",tempcomments); /* comments field for the user */
chars = (ftell(stream) - pos);
if(chars != 801) { /* (entire record should be 801 chars)*/
pos = ftell(stream);
send("]]ERROR on record position %ld, got %d chars, should be 801 !]",pos,chars);
goto endthis;
}
send("%s]",tempname);
tempint=strtoint(templevel); /* check to see if we have privs to read this */
if (G->userpriv[u] < tempint) {
send("]You do not have privledges to access this record!]");
goto more;
}
send("%s]",tempaddress);
send("%s]",tempcity);
send("%s]",tempphone);
removespaces(templevel); /* takes out trailing spaces */
removespaces(tempmachine); /* takes out trailing spaces */
removespaces(templast); /* takes out trailing spaces */
removespaces(temptimes); /* takes out trailing spaces */
removespaces(tempcomments); /* takes out trailing spaces */
send("Level %s, mach. %s, Calls %s, Last %s]Comm: %s]]",templevel,tempmachine,temptimes,templast,tempcomments);
if (!G->cancel[u]) goto more;
goteof:
send("]--EOF--]");
fclose(stream);
endthis:
return;
}
edituserinfo()
{
char tempname[maxnamelength];
char tempalias[maxnamelength];
char temppass[maxnamelength];
char tempaddress[maxnamelength];
char tempcity[maxnamelength];
char tempphone[maxnamelength];
char tempmachine[maxnamelength];
char tempfirst[maxnamelength];
char templevel[maxnamelength];
char tempsettings[maxnamelength];
char tempbirth[maxnamelength];
char tempextras1[maxnamelength];
char tempextras2[maxnamelength];
char tempmins[maxnamelength];
char temptimes[maxnamelength];
char templast[maxnamelength];
char tempupdown[maxnamelength];
char tempcomments[260];
char tchar[260], ans[33], temp[65];
int lnum,tempint,chars;
long int pos;
struct PPP P; /* make the struct here ! */
FILE *stream;
backname:
send("]Enter the user's name or RETURN to quit :");
portsin(ans,30);
send(G->CR[u]);
if (ans[0] == '\0') return;
if ( ! getuserinfo(ans)) { ; /* see if this user exists */
send ("]]Sorry, that name doesn't exist. Please select another...]");
goto backname;
}
showloop:
if ((stream = fopen(":user:userlist", "r")) == NULL) {
print("C> FILE ERROR - cannot open :user:userlist\n");
send("]FILE ERROR - Can't open the user list file !]");
pos = ftell(stream); /* get the current file position */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempname); /* the user's name */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempalias); if (feof(stream)) goto goteof; /* the user's alias */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",temppass); if (feof(stream)) goto goteof; /* the user's password */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",templevel); if (feof(stream)) goto goteof; /* the user's access level */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempaddress); if (feof(stream)) goto goteof; /* the user's address */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempcity); if (feof(stream)) goto goteof; /* the user's city and state */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempphone); if (feof(stream)) goto goteof; /* the user's phone number */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempmachine); if (feof(stream)) goto goteof; /* the user's machine */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempfirst); if (feof(stream)) goto goteof; /* date first logged in */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempsettings); if (feof(stream)) goto goteof; /* user's settings */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempbirth); if (feof(stream)) goto goteof; /* birth info */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempextras1); if (feof(stream)) goto goteof; /* any other info for later use */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempextras2); if (feof(stream)) goto goteof; /* any other info for later use */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",temptimes); if (feof(stream)) goto goteof; /* the number of times this user has been on */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",templast); if (feof(stream)) goto goteof; /* the last date user was on */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempmins); if (feof(stream)) goto goteof; /* the time the user was on last time */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempupdown); if (feof(stream)) goto goteof; /* uploads/downloads */
fgets(tchar,258,stream); sscanf(tchar,"%255[^~]",tempcomments); /* comments field for the user */
chars = (ftell(stream) - pos);
if(chars != 801) { /* (entire record should be 801 chars)*/
pos = ftell(stream);
send("]]ERROR on record position %ld, got %d chars, should be 801 !]",pos,chars);
goto endthis;
}
tempint=strtoint(templevel); /* check to see if we have privs to read this */
if (G->userpriv[u] < tempint) {
send("]You do not have privledges to access this record !]");
goto endthis;
}
send("]User info fields:]");
send(" 1. Name = %s]",tempname);
send(" 2. Alias = %s]",tempalias);
send(" 3. Pass = %s]",temppass);
send(" 4. Level = %s]",templevel);
send(" 5. Address = %s]",tempaddress);
send(" 6. City = %s]",tempcity);
send(" 7. Phone = %s]",tempphone);
send(" 8. Machine = %s]",tempmachine);
send(" 9. First on = %s]",tempfirst);
send("10. Settings = %s]",tempsettings);
send("11. Birth = %s]",tempbirth);
send("12. Allmsg = %s]",tempextras1);
send("13. Extras = %s]",tempextras2);
send("14. Times on = %s]",temptimes);
send("15. Last on = %s]",templast);
send("16. Mins on = %s]",tempmins);
send("17. Up/Down = %s]",tempupdown);
removespaces(tempcomments); /* takes out trailing spaces */
send("18. Comments =]%s]",tempcomments);
send(G->CR[u]);
send("Enter field number to edit or RETURN to exit :");
portsin(ans, 2);
send(G->CR[u]);
if (ans[0] == '\0') goto endthis;
lnum = strtoint(ans);
if (lnum <= 0) goto endthis;
if (lnum > 18) goto endthis;
send("]Enter new text or RETURN to quit:");
if (lnum == 18) {portsin(ans,255);}
else portsin(ans,30);
send(G->CR[u]);
if (ans[0] == '\0') goto endthis;
fclose(stream);
if (lnum == 18) {sprintf(P.passstring,"%-255s~\n",ans);}
else sprintf(P.passstring,"%-30s~\n",ans);
P.field = lnum; /* Replace user's field */
module (3,"putuserfield",&P); /* int mode & module's name & pointer to the P struct */
if ( ! P.uerror){
send("]ERROR TRYING TO UPDATE USER FIELD %d]",lnum);
}
else send("]User's field #%d has been updated..]",lnum);
goto showloop;
goteof:
endthis:
fclose(stream);
endthis1:
getuserinfo(G->username[u]); /* set my file position back */
}
getuserinfo(gettemp)
char *gettemp;
{
char tempname[maxnamelength];
char temp1[maxnamelength],temp2[maxnamelength];
char tchar[260];
int count;
long pos;
FILE *stream;
if ((stream = fopen(":user:userlist", "r")) == NULL) {
print("C> FILE ERROR - cannot open :bbsuser:userlist\n");
send("]FILE ERROR - Can't open the user list file !]");
return FALSE;
}
count = 0;
pos=0;
sprintf(temp2,"%-30s",gettemp); /* Prepare the user name for compare */
strtoupper(temp2);
while (TRUE){
if(fseek(stream,pos,0) != 0) print("C> Fseek failed\n"); /* go to the record */
fscanf(stream,"%30[^~]",tempname); if (feof(stream)) goto goteof; /* the user's name */
strcpy(temp1,tempname); /* save the actual name for later */
strtoupper(tempname);
if (strcmp(tempname,temp2) == 0) {
G->userfilepos[u]=pos; /* save the file position for later reference */
removespaces(temp1); /* takes out trailing spaces */
strcpy(gettemp,temp1); /* make their name correct */
fclose(stream);
return TRUE;
}
otheruser(FALSE); /* do switch */
if ((++count % 10) == 0) {sendnc (".");} /* show dots */
pos=pos+801; /* move up a record */
}
goteof:
fclose(stream);
return FALSE; /* user was not found */
}
checkuserlist() /* goes through the list and checks for correct spacing of data */
{
char tempname[maxnamelength];
char tempalias[maxnamelength];
char temppass[maxnamelength];
char tempaddress[maxnamelength];
char tempcity[maxnamelength];
char tempphone[maxnamelength];
char tempmachine[maxnamelength];
char tempfirst[maxnamelength];
char templevel[maxnamelength];
char tempsettings[maxnamelength];
char tempbirth[maxnamelength];
char tempextras1[maxnamelength];
char tempextras2[maxnamelength];
char tempmins[maxnamelength];
char temptimes[maxnamelength];
char templast[maxnamelength];
char tempupdown[maxnamelength];
char tempcomments[260];
char temp1[maxnamelength], temp2[maxnamelength];
char tchar[260], temp[65];
int count,got,chars;
long pos;
FILE *stream;
send("]Checking userlist by reading all records and checking for extra or missing chars]");
if ((stream = fopen(":user:userlist", "r")) == NULL) {
print("C> FILE ERROR - cannot open :user:userlist\n");
send("]FILE ERROR - Can't open the user list file !]");
return (FALSE);
}
count = 0;
while (TRUE){
pos = ftell(stream); /* get the current file position */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempname); /* the user's name */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempalias); if (feof(stream)) goto goteof; /* the user's alias */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",temppass); if (feof(stream)) goto goteof; /* the user's password */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",templevel); if (feof(stream)) goto goteof; /* the user's access level */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempaddress); if (feof(stream)) goto goteof; /* the user's address */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempcity); if (feof(stream)) goto goteof; /* the user's city and state */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempphone); if (feof(stream)) goto goteof; /* the user's phone number */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempmachine); if (feof(stream)) goto goteof; /* the user's machine */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempfirst); if (feof(stream)) goto goteof; /* date first logged in */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempsettings); if (feof(stream)) goto goteof; /* user's settings */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempbirth); if (feof(stream)) goto goteof; /* birth info */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempextras1); if (feof(stream)) goto goteof; /* any other info for later use */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempextras2); if (feof(stream)) goto goteof; /* any other info for later use */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",temptimes); if (feof(stream)) goto goteof; /* the number of times this user has been on */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",templast); if (feof(stream)) goto goteof; /* the last date user was on */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempmins); if (feof(stream)) goto goteof; /* the time the user was on last time */
fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%30[^~]",tempupdown); if (feof(stream)) goto goteof; /* uploads/downloads */
fgets(tchar,258,stream); sscanf(tchar,"%255[^~]",tempcomments); /* comments field for the user */
chars = (ftell(stream) - pos);
if(chars != 801) { /* (entire record should be 801 chars)*/
pos = ftell(stream);
send("]]ERROR in userlist at position %ld ! Check it out !]",pos);
print("\nC> ERROR on record position %ld, got %d chars, should be 801 !\n",pos,chars);
fclose(stream);
return FALSE;
}
otheruser(FALSE); /* do switch */
if ((++count % 10) == 0) {sendnc (".");} /* show dots */
}
goteof:
fclose(stream);
send("]User list checks out OK !]");
return TRUE; /* records are OK */
}
backwardsfile(thefile)
char *thefile;
{
char temp[520],output[520],nexttime[520];
long int seek,startfile,endfile, strstart, strend, got,toget;
int endoffile,count,i,err1,a;
FILE *stream;
if ((stream = fopen(thefile, "r")) == NULL) {
print("C> FILE ERROR - cannot open \"%s\"\n",thefile);
send("]FILE ERROR - Cannot open \"%s\"]",thefile);
return;
}
strcpy (nexttime,""); /* blank this out for now */
startfile=ftell(stream);
if(err1=fseek(stream,0,2) != 0) print("Fseek to end failed\n"); /* go to end of file */
endfile=ftell(stream);
seek=endfile-512; /* back up 512 */
endoffile=FALSE;
toget=512; /* start out getting 512 characters */
while(!endoffile) {
if (seek < 0) {
toget=512+seek; /* get the difference in characters, seek is negative */